#include "animal.h"
#include "dog.h"

int main() {
    // 创建基类对象
    MyAnimal *animal = g_object_new(MY_TYPE_ANIMAL, NULL);
    my_animal_speak(animal);  // 输出: (Animal) ???
    g_object_unref(animal);
    
    // 创建子类对象
    MyDog *spike = my_dog_new("Spike");
    my_animal_speak(MY_ANIMAL(spike));  // 输出: (Dog) Spike: Woof!
    g_object_unref(spike);
    
    // 多态示例
    MyAnimal *animals[2] = {
        g_object_new(MY_TYPE_ANIMAL, NULL),
        MY_ANIMAL(my_dog_new("Rex"))
    };
    
    for (int i = 0; i < 2; i++) {
        my_animal_speak(animals[i]);
        g_object_unref(animals[i]);
    }
    
    return 0;
}